namespace ConsoleApp8
{
    internal class Program
    {

        static void Main(string[] args)
        {
            const int calendarlong = 35, calendarheight = 15;
            int i = 3;
            DateTime day = DateTime.Parse("2022.1.01");
            DateTime start = DateTime.Parse("2022.1.01");
            DateTime finish = DateTime.Parse("2023.1.01");
            do
            {
                int j = (day.Month - 1) / 3, k = (day.Month - 1) % 3;
                if (day.Month - start.Month >=0)//输出月份和星期
                {

                    Console.SetCursorPosition(calendarlong * k, j * calendarheight);
                    Console.WriteLine("{0}月", day.Month);
                    Console.SetCursorPosition(calendarlong * k, j * calendarheight + 1);
                    Console.Write("日  一   二   三   四   五   六");
                    Console.Write('\n');
                }
                if ((int)day.DayOfWeek == 6)
                {
                    Console.SetCursorPosition( (calendarlong / 7)*(int)day.DayOfWeek+ calendarlong * k, i+ j * calendarheight);//放置周六时的光标位置
                    Console.Write("{0}", day.Day);
                    i++;//光标换行
                }
                if ((int)day.DayOfWeek != 6&& (int)day.DayOfWeek != 7)
                {
                    Console.SetCursorPosition( (calendarlong / 7) * (int)day.DayOfWeek+ calendarlong * k, i+ j * calendarheight);
                    Console.Write("{0}",  day.Day);
                }
                if((int)day.DayOfWeek ==7)//周日在第一行单独放置
                {
                    Console.SetCursorPosition( calendarlong / 7+ calendarlong * k, i+ j * calendarheight);
                    Console.Write("{0}", day.Day);
                }
                day =day.AddDays(1);
                if (day.Day == 1)//一个月走完之后i重置为3从星期下一行开始输入
                {
                    i = 3;
                }
               
            } while (day != finish);
            
        }
    }
}